﻿<div class="d-flex flex-column align-start mb-2 app-heading">
    <h1 class="m-heading text-h3 text-sm-h3" id="@Meta.Title.HashToAnchorString()">@Meta.Title</h1>
</div>

<MMarkdownIt Source="@Meta.Description" NoWrapper Scope="desc"></MMarkdownIt>

<div class="@(string.IsNullOrWhiteSpace(Meta.Description) ? "" : "mt-n3") mb-4">
    @if (!string.IsNullOrWhiteSpace(Meta.Tag))
    {
        <MChip Class="mr-2" Small Color="primary" Tonal>@Meta.Tag</MChip>
    }

    @if (AdditionalTags.Any())
    {
        foreach (var item in AdditionalTags)
        {
            <MChip Class="mr-2" Small Color="primary" Tonal>@item</MChip>
        }
    }
    
    @if (Meta.Release != null)
    {
        var href = "/blazor/getting-started/release-notes?v=" + Meta.Release;
        <MChip Small Color="green" Href="@href" Tonal>@Meta.Release</MChip>
    }
</div>

@ChildContent

@code {

    [Parameter]
    [EditorRequired]
    public FrontMatterMeta Meta { get; set; } = null!;

    [Parameter]
    public List<string> AdditionalTags { get; set; } = new();

    [Parameter]
    public RenderFragment? ChildContent { get; set; }

    public override async Task SetParametersAsync(ParameterView parameters)
    {
        await base.SetParametersAsync(parameters);

        ArgumentNullException.ThrowIfNull(Meta);
    }

}
